package com.dfbz.service.impl;

import com.dfbz.dao.MeetingDao;
import com.dfbz.model.Meeting;
import com.dfbz.pojo.PageEntity;
import com.dfbz.service.MeetingService;
import com.dfbz.utils.PageUtil;

import java.util.ArrayList;
import java.util.List;

public class MeetingServiceImpl implements MeetingService {
    MeetingDao meetingDao=new MeetingDao();
    @Override
    public Meeting findById(Integer id) {
        return meetingDao.findByid(id);
    }

    @Override
    public ArrayList<Meeting> findList() {
        return meetingDao.findList();
    }

    @Override
    public void save(Meeting meeting) {
        meetingDao.save(meeting);
    }

    @Override
    public void deleteById(Integer id) {
        meetingDao.deleteById(id);
    }

    @Override
    public void update(Meeting meeting) {
        meetingDao.update(meeting);
    }

    @Override
    public PageEntity<Meeting> findPage(Integer currPage, String meeting_title, Integer status) {
        PageEntity<Meeting> pageEntity = new PageEntity<>();
        List<Meeting> pageData = meetingDao.findAllMeeting(meeting_title, status, (currPage - 1) * pageEntity.getPageSize(), pageEntity.getPageSize());
        Integer totalCount = meetingDao.coutByTilSta(meeting_title, status);
        return PageUtil.getPageEntity(pageEntity,currPage,pageData,totalCount);
    }
}
